fix: repair failing tests and type errors across monorepo - #153
Open
stooit wants to merge 1 commit into
Open
Conversation
…, bun-types - bunfig.toml: replace unsupported `environment` key with `preload` so the happy-dom global registrator loads (fixes `document is not defined`) - api.ts: useThrottle -> useDebounce after the hook was renamed in @e2e/utils (public useSearchDebounce name preserved) - Button: apply aria-label to the element and fall back to string children before "Button"; dev-only warn when icon-only lacks a label [WCAG 4.1.2] - date.ts: strip en-AU locale zero-padding via formatToParts -> D/MM/YYYY - tsconfig.json: wire already-installed bun-types so `bun:test` resolves bun test: 13 pass / 0 fail. tsc --noEmit: exit 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests and eliminates all
tsc --noEmittype errors across the monorepo. The bugs spanned four packages plus test-harness and build config.Before: 4 pass / 9 fail ·
tsc --noEmitexit 2 (4 errors)After: 13 pass / 0 fail ·
tsc --noEmitexit 0Root causes & fixes
bunfig.tomlenvironment = "happy-dom"is a Jest/Vitest key that Bun silently ignores, so@testing-library/reactran with no DOM →document is not defined(6 failures).preload = ["./packages/ui/test/setup.ts"], which actually registers the happy-dom global.apps/web/src/lib/api.tsuseThrottlefrom@e2e/utils, but the hook was renamed touseDebounce→SyntaxError: export not found.useDebounce. The publicuseSearchDebouncename is unchanged, so no consumer breakage.packages/ui/.../Button.tsxaria-labelwas never rendered onto the element.aria-labelon the element, falling back to stringchildrenbefore a generic"Button"; dev-onlyconsole.warnwhen an icon-only button lacks a label. [WCAG 2.2 SC 4.1.2]packages/utils/.../date.tsen-AUIntl.DateTimeFormatzero-pads the day (01/03/2024); test expects day-first, unpadded.formatToPartsandNumber()the day →1/03/2024(D/MM/YYYY). Hardcodeden-AU, locale-proof.tsconfig.jsonbun-types(already a devDependency) wasn't wired in, sobun:testwas unresolvable → 4×TS2307."types": ["bun-types"]tocompilerOptions. No new dependency.Verification
bun test→ 13 pass / 0 fail./node_modules/.bin/tsc --noEmit→ exit 0, no errorsAssumptions / notes
bun-typeswas already declared and installed — only the tsconfig wiring was missing).formatDateoutput1/03/2024has asymmetric padding (unpadded day, zero-padded month) — this is forced by the un-editable test assertion/^1/. It diverges slightly fromformatDateTime's format; a follow-up could align them, but that would require changing behaviour the tests pin.children-string fallback improves on a naive hardcoded"Button"(which would have masked real accessible names), but full node-tree name recovery is out of scope — passing an explicitaria-labelremains the intended API, and the dev warning steers callers there.typesin tsconfig disables automatic@types/*inclusion; harmless today (React types resolve via explicit import), but a future@types/nodeetc. would need appending to that array.🤖 Generated autonomously.